package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-04-07
 * Time: 18:41
 */
public class UDPDictSever extends UdpEchoServer {
    private Map<String, String> dict = new HashMap<>();


    public UDPDictSever(int port) throws SocketException {
        super(port);
        dict.put("dog","小狗");
        dict.put("cat","小猫");
        dict.put("pig","小猪");

    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"该单词未查到");
    }

    public static void main(String[] args) throws IOException {
        UDPDictSever udpDictSever=new UDPDictSever(9090);
        udpDictSever.start();

    }
}
